#ifndef GDR_H_
#define GDR_H_

#include "recbase.h"
#include "rectype.h"
#include "stdffield.h"
#include <vector>


using namespace std;

// declaration
// class opsrc::stdf::GdrStdfField;

namespace opsrc {
    namespace stdf {


        class GdrStdfField;

        class Gdr : public opsrc::stdf::RecBase
        {
        public:
            Gdr(stdf_rec stdfrec,  int reclen, std::ios::pos_type fileRecFirstBytePosition, int orderindex, endian e, char* buf);
            virtual ~Gdr();

            const StdfField<int> getFieldCount() const;
            void setFieldCount(StdfField<int> fldcnt);
            void readFields(char *buf);

            gdr_data_typ checkDataFieldType(int index) const;
            GdrStdfField* getGdrStdfField(int index) const;

        protected:
            Gdr();

        protected:
            GdrStdfField* createDataField(char* buf, int curpos);

        private:
            StdfField<int> fld_cnt;
            std::vector<GdrStdfField*> cont;
            endian en;
            bool decodeFields;

        };
        /*
FLD_CNT U*2 Count of data fields in record
GEN_DATA V*n Data type code and data for one field
(Repeat GEN_DATA for each data field)
Notes on Specific Fields:
GEN_DATA Is repeated FLD_CNT number of times. Each GEN_DATA field consists of a data type code
followed by the actual data. The data type code is the first unsigned byte of the field.
Valid data types are:
0 = B*0 Special pad field, of length 0 (See note below)
1 = U*1 One byte unsigned integer
2 = U*2 Two byte unsigned integer
3 = U*4 Four byte unsigned integer
4 = I*1 One byte signed integer
5 = I*2 Two byte signed integer
6 = I*4 Four byte signed integer
7 = R*4 Four byte floating point number
8 = R*8 Eight byte floating point number
10 = C*n Variable length ASCII character string
(first byte is string length in bytes)
11 = B*n Variable length binary data string
(first byte is string length in bytes)
12 = D*n Bit encoded data
(first two bytes of string are length in bits)
13 = N*1 Unsigned nibble
*/
    }	// namespace stdf
}		// namespace opsrc

#endif /*GDR_H_*/
